/*
 * LoadingWindow.fx
 *
 * Created on 18-may-2009, 15:55:26
 */

package webooksfx_desktop.view.components;

import javafx.scene.CustomNode;
import javafx.scene.Group;
import javafx.scene.Node;
import javafx.scene.paint.Color;
import javafx.scene.paint.LinearGradient;
import javafx.scene.paint.Stop;
import javafx.scene.shape.Rectangle;
import javafx.scene.text.Font;
import javafx.scene.text.Text;
import webooksfx_desktop.view.components.effects.effect_Fade;
import webooksfx_desktop.view.components.LoadingIcon;
import javafx.scene.effect.GaussianBlur;

/**
 * @author Administrador
 */
public class LoadingWindow extends CustomNode {
	public var width : Integer = 50;
	public var height : Integer = 30;
	public var offset : Integer = 10;
	var nodo : Node = null;
	var effectFade : effect_Fade = null;
	var texto : String = "Cargando";
	var icono : LoadingIcon = null;
	public override function create(): Node {
		nodo =  Group {
			content: [
				/*Rectangle {
					effect: GaussianBlur {
						radius: 35
					}
					width: bind width + offset
					height: bind height + offset
					arcWidth:30
					arcHeight:30
					fill: Color.BLUE
				},*/Rectangle {
					translateX: bind ( offset / 2 )
					translateY: bind ( offset / 2 )
					arcWidth: 30
					arcHeight: 30
					width: bind width
					height: bind height
					stroke: Color.GRAY
					strokeWidth: 3
					fill: LinearGradient {
						startX : 0.0
						startY : 0.0
						endX : 0.0
						endY : 0.6
						stops: [
							Stop {
								color : Color.web("#14243D");
								offset: 0.0
							},
							Stop {
								color : Color.web("#010813");
								offset: 1.0
							}
						]
					}					
				},Text {
					font : Font {
						size: 16
					}
					translateX: bind ( width / 2 ) - 30
					translateY: 16 + 20//FontSize + 20
					content: bind texto
					fill: Color.WHITE
				},icono = LoadingIcon{

					translateX: bind ( width / 2 )
					translateY: bind height - ( icono.size ) + 10
				}
			]
		};
		//==========================================================================================
		// ASIGNA EL EFECTO FADE AL NODO
		//==========================================================================================
		return effectFade = effect_Fade{
			nodo: nodo
		};
	}

	public function showLoad() : Void {
		effectFade.show();
		icono.play();
	}

	public function hideLoad() : Void {
		effectFade.hide();
		icono.stop();
	}
}